package mycompany.listener;

import java.util.logging.Logger;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import mycompany.service.UserService;

/**
 *
 * @author Volodymyr Lavrynovych <volodya.lavrynovych@gmail.com>
 */
public class SessionListener implements HttpSessionListener {
    
    private static final Logger log = Logger.getLogger(SessionListener.class.toString());
    private UserService userService;
    
    public SessionListener(){
        userService = UserService.getInstance();
    }
    
    public void sessionCreated(HttpSessionEvent hse) {
        userService.addUser(hse.getSession());
    }

    public void sessionDestroyed(HttpSessionEvent hse) {
        userService.removeUser(hse.getSession());
    }
    
}
